home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / lib / partman / active_partition / 45basicfilesystems / choices next >
Encoding:
Text File  |  2009-04-19  |  3.5 KB  |  142 lines

  1. #!/bin/sh
  2.  
  3. . /usr/share/debconf/confmodule
  4.  
  5. set -e
  6.  
  7. dev=$1
  8. id=$2
  9. part=$dev/$id
  10.  
  11. cd $dev
  12.  
  13. [ -f $part/method -a -f $part/acting_filesystem ] || exit 0
  14.  
  15. method=$(cat $part/method)
  16. filesystem=$(cat $part/acting_filesystem)
  17.  
  18. case "$filesystem" in
  19.     ext2|fat16|fat32|ntfs)
  20.     :
  21.     ;;
  22.     *)
  23.     exit 0
  24.     ;;
  25. esac
  26.  
  27. choice_mountpoint () {
  28.     case "$filesystem" in
  29.         ext2|fat16|fat32|ntfs)
  30.         if [ -f $part/mountpoint ]; then
  31.             mp=$(cat $part/mountpoint)
  32.         else
  33.             db_metaget partman-basicfilesystems/text/no_mountpoint description
  34.             mp="$RET"
  35.         fi
  36.         db_metaget partman-basicfilesystems/text/specify_mountpoint description
  37.         printf "mountpoint\t%s\${!TAB}%s\n" "$RET" "$mp"
  38.         ;;
  39.     esac
  40. }
  41.  
  42. choice_options () {
  43.     if [ "$filesystem" = ntfs ]; then
  44.         # no mount options support yet (requires translations)
  45.         return
  46.     fi
  47.     db_metaget partman-basicfilesystems/text/options description
  48.     printf "options\t%s\${!TAB}%.45s\n" "$RET" "$(get_mountoptions $dev $id)"
  49. }
  50.  
  51. choice_format_swap () {
  52.     if [ "$method" = swap ] && [ -f $part/detected_filesystem ] && \
  53.        [ "$(cat $part/detected_filesystem)" = linux-swap ];    then
  54.         db_metaget partman-basicfilesystems/text/format_swap description
  55.         description="$RET"
  56.         if [ -f $part/format ]; then
  57.             db_metaget partman-basicfilesystems/text/yes description
  58.             printf "dont_format_swap\t%s\${!TAB}%s\n" "$description" "${RET}"
  59.         else
  60.             db_metaget partman-basicfilesystems/text/no description
  61.             printf "format_swap\t%s\${!TAB}%s\n" "$description" "${RET}"
  62.         fi
  63.     fi
  64. }
  65.  
  66. choice_label () {
  67.     # allow to set label only if the partition is to be formatted
  68.     [ -f $part/format ] || return 0
  69.     [ ! -f $part/formatted \
  70.       -o $part/formatted -ot $part/method \
  71.       -o $part/formatted -ot $part/filesystem ] || return 0
  72.     case "$filesystem" in
  73.         ext2)
  74.         if [ -f $part/label ]; then
  75.             label=$(cat $part/label)
  76.         else
  77.             db_metaget partman-basicfilesystems/text/none description
  78.             label=$RET
  79.         fi
  80.         db_metaget partman-basicfilesystems/text/specify_label description
  81.         printf "label\t%s\${!TAB}%s\n" "$RET" "$label"
  82.         ;;
  83.         _no_fat16|_no_fat32) # we dont have tools to set label of FAT file systems
  84.         if [ -f $part/label ]; then
  85.             label=$(cat $part/label)
  86.         else
  87.             db_metaget partman-basicfilesystems/text/none description
  88.             label=$RET
  89.         fi
  90.         db_metaget partman-basicfilesystems/text/specify_label description
  91.         printf "label\t%s\${!TAB}%s\n" "$RET" "$label"
  92.         ;;
  93.     esac
  94. }
  95.  
  96. choice_reserved () {
  97.     local reserved
  98.     [ "$filesystem" = ext2 ] || return 0
  99.     # allow to set reserved space only if the partition is to be formatted
  100.     [ -f $part/format ] || return 0
  101.     [ ! -f $part/formatted \
  102.       -o $part/formatted -ot $part/method \
  103.       -o $part/formatted -ot $part/filesystem ] || return 0
  104.     if [ -f $part/reserved_for_root ]; then
  105.         reserved=$(cat $part/reserved_for_root)
  106.     else
  107.         reserved=5
  108.     fi
  109.     db_metaget partman-basicfilesystems/text/reserved_for_root description
  110.     printf "reserved_for_root\t%s\${!TAB}%s\n" "$RET" "$reserved%"
  111. }
  112.  
  113. choice_usage () {
  114.     local usage
  115.     [ "$filesystem" = ext2 ] || return 0
  116.     # allow to set usage only if the partition is to be formatted
  117.     [ -f $part/format ] || return 0
  118.     [ ! -f $part/formatted \
  119.       -o $part/formatted -ot $part/method \
  120.       -o $part/formatted -ot $part/filesystem ] || return 0
  121.     if [ -f $part/usage ]; then
  122.         usage=$(cat $part/usage)
  123.     else
  124.         db_metaget partman-basicfilesystems/text/typical_usage description
  125.         usage=$RET
  126.     fi
  127.     db_metaget partman-basicfilesystems/text/usage description
  128.     printf "usage\t%s\${!TAB}%s\n" "$RET" "$usage"
  129. }
  130.  
  131. choice_mountpoint
  132.  
  133. choice_options
  134.  
  135. choice_format_swap
  136.  
  137. choice_label
  138.  
  139. choice_reserved
  140.  
  141. choice_usage
  142.